package cn.jolyoulu.adminweb.controller.com;


import cn.jolyoulu.common.web.security.permission.Permission;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import cn.jolyoulu.adminweb.entity.vo.DictSelectVO;
import cn.jolyoulu.adminweb.entity.vo.UserMenuVO;
import cn.jolyoulu.adminweb.entity.vo.VerifyCodeImgVO;
import cn.jolyoulu.adminweb.service.ApiCommonService;
import cn.jolyoulu.common.web.entity.ResultInfo;

import java.util.List;

/**
 * 公共
 * @Author LuZhouJin
 * @Date 2023/3/15
 */
@RestController
@RequestMapping("/api/common")
public class ApiCommonController {

    @Autowired
    private ApiCommonService apiCommonService;

    /**
     * 获取验证码
     */
    @Permission(flag = false)
    @GetMapping("/verifyCodeImg")
    public ResultInfo<VerifyCodeImgVO> verifyCodeImg(){
        VerifyCodeImgVO res = apiCommonService.verifyCodeImg();
        return ResultInfo.success(res);
    }

    /**
     * 获取下拉框
     */
    @Permission(flag = false)
    @GetMapping("/dict/select/{dictType}")
    public ResultInfo<List<DictSelectVO>> dictSelect(@PathVariable String dictType){
        List<DictSelectVO> res = apiCommonService.dictSelect(dictType);
        return ResultInfo.success(res);
    }

    /**
     * 获取用户菜单
     */
    @Permission(flag = false)
    @GetMapping("/user/menu")
    public ResultInfo<List<UserMenuVO>> userMenu(){
        List<UserMenuVO> res = apiCommonService.userMenu();
        return ResultInfo.success(res);
    }
}
